package _02_第二季._01_排序;

import _02_第二季._01_排序.tools.Asserts;
import _02_第二季._01_排序.tools.Integers;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) {
        Integer[] array = Integers.random(60000,1,30000);

        sort(array,
            /*new Bubble01<Integer>(),
            new Selection02<Integer>(),*/
            new HeapSort03<Integer>(),
            /*new InsertionSort04<Integer>(),*/
            new MergeSort05<Integer>(),
            new QuickSort06<Integer>(),
            new ShellSort07<Integer>(),
            new CountingSort08());
    }

    static void sort(Integer[] array,Sort... sorts){
        for (Sort sort : sorts) {
            Integer[] newArray = Integers.copy(array);
            //调用父类方法去排序
            sort.sort(newArray);
            Asserts.test(Integers.isAscOrder(newArray)); //是否是升序排列
        }
        Arrays.sort(sorts);
        for (Sort sort : sorts) {
            System.out.println(sort);
        }
    }
}
